<fieldset>
	<legend>文章列表</legend>

	<div class="toolbar">
		<a href="/admin/article/list?status=0" {{if eq .status 0}}class="active"{{end}}>已发布</a>
		<span class="divider">|</span>
		<a href="/admin/article/list?status=1" {{if eq .status 1}}class="active"{{end}}>草稿箱({{.count_1}})</a>
		<span class="divider">|</span>
		<a href="/admin/article/list?status=2" {{if eq .status 2}}class="active"{{end}}>回收站({{.count_2}})</a>
	</div>

	<div class="search-form">
	<form action="/admin/article/list?status={{.status}}" method="post" class="form-inline">
		<select name="searchtype" class="span2" >
		<option value="title" {{if eq .searchtype "title"}}selected{{end}}>标题</option>
		<option value="author" {{if eq .searchtype "author"}}selected{{end}}>作者</option>
		<option value="tag" {{if eq .searchtype "tag"}}selected{{end}}>标签</option>
		</select>
		<input name="keyword" id="keyword" value="{{.keyword}}" class="input" placeholder="关键字" type="text" />
		<button type="submit" class="btn">搜索</button>
	</form>
	</div>

	<form method="post" name="p" action="/admin/article/batch">
	<table class="table table-list">
		<thead>
			<tr>
				<th width="30"><input type="checkbox" name="all" value="0" onclick="checkall('ids[]', this)" /></th>
				<th width="50">ID</th>
				<th>标题</th>
				<th width="150">类别</th>
				<th width="60">点击量</th>
				<th width="60">发布人</th>
				<th width="120">发布时间</th>
				<th width="80">操作</th>
			</tr>
		</thead>
		<tbody>
		{{range $k, $v := .list}}
		<tr>
			<td><input type="checkbox" name="ids[]" value="{{$v.Id}}" /></td>
			<td>{{$v.Id}}</td>
			<td class="hl_title">
				{{if $v.Istop}}
				<i class="icon-arrow-up" title="置顶"> </i>
				{{end}}
				<a href="{{$v.Link}}" target="_blank">{{str2html $v.ColorTitle}}</a>
				{{if $v.Urltype}}
				<span class="label label-important">页面</span>
				{{end}}
			</td>
			<td class="hl_tag">{{str2html $v.TagsLink}}</td>
			<td>{{$v.Views}}</td>
			<td class="hl_author">{{$v.Author}}</td>
			<td>{{date $v.Posttime "m月d日 H:i:s"}}</td>
			<td><a href="/admin/article/edit?id={{$v.Id}}">编辑</a> | <a href="/admin/article/delete?id={{$v.Id}}" onclick="return del_confirm()">删除</a></td>
		</tr>
		{{end}}
		</tbody>
		<tfoot>
			<tr>
				<td colspan="20">{{str2html .pagebar}}</td>
			</tr>
			<tr>
				<td width="30"><input type="checkbox" name="all" value="0" onclick="checkall('ids[]', this)" /></td>
				<td colspan="20">
					<select name="op" id="op">
					<option value="">批量操作</option>
					<option value="topub" >移至已发布</option>
					<option value="todrafts" >移至草稿箱</option>
					<option value="totrash" >移至回收站</option>
					<option value="delete" >删除</option>
					</select>
					<button type="submit" class="btn btn-small">应用</button>
				</td>
			</tr>
		</tfoot>
	</table>
	</form>

</fieldset>

<script type="text/javascript">
$(function() {
	searchtype = $(":input[name='searchtype']").children("option:selected").val();
	keyword = $(":input[name='keyword']").val();
	if (keyword != "") {
		re = new RegExp(keyword, "g");
		switch (searchtype) {
			case "title":
				$(".hl_title").each(function(){
					$(this).children("a").html($(this).children("a").html().replace(re, "<span style='color:red'>"+keyword+"</span>"));
				});
				break;
			case "author":
				$(".hl_author").each(function(){
					$(this).html($(this).html().replace(re, "<span style='color:red'>"+keyword+"</span>"));
				});
				break;
			case "tag":
				$(".hl_tag").each(function(){
					$(this).children("a").html($(this).children("a").html().replace(re, "<span style='color:red'>"+keyword+"</span>"));
				});
				break;
		}
		
	}
})
</script>